package com.example.web14.config;

import com.example.web14.domain.Student;
import com.example.web14.domain.Ticket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {
    //把票券对象交给Spring容器管理  给学生加形参 向IOC容器要票券对象 IOC会自动创建票券对象并赋值给形参
    @Bean
    public Student student(Ticket ticket) {
        System.out.println("我是MyConfig中的student方法");
        return new Student("张三丰", "20", ticket);
    }
    @Bean
    public Ticket ticket() {
        System.out.println("我是MyConfig中的ticket方法");
        return new Ticket("电影票", "100", "10:00", "深圳");
    }
}
